//This module helps when several loader needs to be finished first before 
//continue
define(
[],
function(){
	return {
		create: function() {
			var _callback;
			var _params;
			var _counter;

			var _self = {
				init: function(callback, params) {
					_callback = callback;
					_params = params;
					_counter = 0;

					return _self;
				},

				addLoader: function() {
					++_counter;
				},

				finishLoader: function() {
					if(--_counter == 0) 
						_callback(_params);
					else if(_counter < 0)
						throw "Inconsisten counter, currently < 0!";
				}
			};

			return _self;
		}
	}	
});